<#include "*/component/Tags.ftl"/>
<@Title/>
<@ClassAnnotation>
@Data
@SqlTarget(target = "${entity.table.name} ${entity.table.alias}")
@SqlTableAlias(alias = "${entity.table.alias}")
</@ClassAnnotation>
<@Class>

${'\t'}@Data@AllArgsConstructor@Builder
${'\t'}@SqlTableAlias(aliasFromClass = ${clazz.name}.class)
${'\t'}public static class QueryCondition extends NotDeleteCondition {
${'\t'}${'\t'}@Getter
${'\t'}${'\t'}@SqlTableAlias(aliasFromClass = QueryCondition.class)
${'\t'}${'\t'}@SqlConditionLogical(logicalOperator = LogicalOperator.OR)
${'\t'}${'\t'}public static class KeywordCondition {
<#list entity.fields as field >
<@Field field=field onlyString=true tabTimes=3 type=7>
${'\t'}${'\t'}${'\t'}@SqlColumn(name = "${field.column.name}")
${'\t'}${'\t'}${'\t'}@SqlCondition(conditionOperator = ConditionOperator.INCLUDE)
</@Field>
</#list>

${'\t'}${'\t'}${'\t'}public KeywordCondition(String keyword) {
<#list entity.fields as field>
<#if field.type == 'String'&&!field.column.isCombine>
${'\t'}${'\t'}${'\t'}${'\t'}this.${field.name} = keyword;
</#if>
</#list>
${'\t'}${'\t'}${'\t'}}
${'\t'}${'\t'}}

${'\t'}${'\t'}@SqlCondition(multiple = true)
${'\t'}${'\t'}private QueryCondition.KeywordCondition keywordCondition;
<#list entity.fields as field>
<#if field.condition??>
${'\t'}${'\t'}@SqlColumn(name = "${field.column.name}")
${'\t'}${'\t'}@SqlCondition(conditionOperator = ConditionOperator.<#if field.condition=='like'>INCLUDE<#else>EQUAL</#if>)
${'\t'}${'\t'}private ${field.type} ${field.name};
</#if>
</#list>

${'\t'}${'\t'}public QueryCondition() {

${'\t'}${'\t'}}

${'\t'}${'\t'}public QueryCondition(String keyword) {
${'\t'}${'\t'}${'\t'}this.keywordCondition = new QueryCondition.KeywordCondition(keyword);
${'\t'}${'\t'}}
${'\t'}}

${'\t'}@Getter
${'\t'}@SqlTableAlias(aliasFromClass = ${clazz.name}.class)
${'\t'}public static class QueryOrderBy {
${'\t'}${'\t'}/**
${'\t'}${'\t'}* 更新时间
${'\t'}${'\t'}*/
${'\t'}${'\t'}@SqlColumn(name = "update_time")
${'\t'}${'\t'}@SqlOrderBy(index = 1)
${'\t'}${'\t'}private OrderBy updateTime = OrderBy.desc;

${'\t'}${'\t'}public QueryOrderBy() {

${'\t'}${'\t'}}

${'\t'}${'\t'}public QueryOrderBy(OrderBy updateTime) {
${'\t'}${'\t'}${'\t'}this.updateTime = updateTime;
${'\t'}${'\t'}}
${'\t'}}

<#list entity.fields as field>
<@Field field=field useSwagger=true>
${'\t'}@SqlColumn(name = "${field.column.name}")
</@Field>
</#list>
${'\t'}/**
${'\t'}* 创建时间
${'\t'}*/
${'\t'}@ApiModelProperty(value = "创建时间")
${'\t'}@SqlColumn(name = "create_time")
${'\t'}private Date createTime;
${'\t'}/**
${'\t'}* 更新时间
${'\t'}*/
${'\t'}@ApiModelProperty(value = "更新时间")
${'\t'}@SqlColumn(name = "update_time")
${'\t'}private Date updateTime;
${'\t'}/**
${'\t'}* 逻辑删除标志
${'\t'}*/
${'\t'}@ApiModelProperty(value = "逻辑删除标志")
${'\t'}@SqlColumn(name = "deleted")
${'\t'}private Boolean deleted;
</@Class>
